<?php

	class MediaExtensionModel extends EbTableSQLModel
	{
		public function __construct()
		{
			parent::init("md_extension",null,"ex_id");
		}
				
		public function getColumns()
		{
			return array(
				new EbTableColumn("ex_id","int",true,EB_PRIMARY_KEY,true),
				new EbTableColumn("name",'varchar(32)'),
				new EbTableColumn("description",'text',false),
				new EbTableColumn("icon",'varchar(128)',false)
			);
		}
		
		public function selectByFilename($value)
		{
			$buffer = $this->selectByName(EbFilesToolkit::getExtension($value));
			
			return $buffer[0]->ex_id;
		}
		
		public function create()
		{
			if (parent::create())
			{
				parent::insert((object) array('name' => 'gif'));
				parent::insert((object) array('name' => 'bmp'));
				parent::insert((object) array('name' => 'jpg'));
				parent::insert((object) array('name' => 'png'));
				parent::insert((object) array('name' => 'php'));
				parent::insert((object) array('name' => 'cfm'));
				parent::insert((object) array('name' => 'zip'));
				parent::insert((object) array('name' => 'doc'));
				parent::insert((object) array('name' => 'docx'));
				parent::insert((object) array('name' => 'xls'));
				parent::insert((object) array('name' => 'mp3'));
				parent::insert((object) array('name' => 'flv'));
		
				return true;
			}	
			else
			{
				return false;
			}
		}
	}